home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / technical documentation / develop / additional articles / developing symbiotic apps / symbiotic samples / uappleevents.cp folder / uappleevents.h < prev   
Encoding:
Text File  |  1996-10-27  |  2.6 KB  |  68 lines

  1. // UAppleEvents © 1996 Nick Beadman
  2. //    Utility class for helping handle the AppleEvent Manager
  3.  
  4. #pragma once
  5.  
  6. class UAppleEvents
  7. {
  8. // object specification helpers
  9. public:
  10.     // get the container of an object specifier
  11.     static OSErr GetContainer(const AEDesc& inObjectSpecifier, AEDesc& outContainer);
  12.     
  13. // sending apple events
  14. public:
  15.     //  waiting for a reply (will return an OSErr if the reply contains one)
  16.     static OSErr SendWaitReply(const AppleEvent& inEvent, AppleEvent& outReply, Int32 inTimeout = kAEDefaultTimeout, AESendMode inAdditionalAttr = 0);
  17.     // just do it
  18.     static OSErr SendNoReply(const AppleEvent& inEvent, AESendMode inAdditionalAttr = 0);
  19.  
  20. // check a reply for an error string or OSErr (returns whether there is one in the reply)
  21. public:
  22.     static Boolean ExtractOSErr(const AppleEvent& inReply, OSErr& outErr);
  23.     static Boolean ExtractErrorString(const AppleEvent& inReply, StringPtr outString);
  24.  
  25. // handling interaction with user, call this function before poping up a modal dialog
  26. public:
  27.     static OSErr InteractWithUser(NMRecPtr inNotificationRequest = nil, Int32 inTimeout = kAEDefaultTimeout);
  28.  
  29. // must be called at application startup for recording to work
  30. public:
  31.     static OSErr InitRecordability(void);
  32.  
  33. // recording an apple event (send to self without executing)
  34. public:
  35.     static OSErr Record(const AppleEvent& inEvent);
  36.  
  37. // make a self addressed address desc (only here because UAppleEventsMgr's is private)
  38. public:
  39.     static OSErr MakeSelfAddressDesc(AEAddressDesc& outSelfAddressDesc);
  40.  
  41. // comparison routines
  42. public:
  43.     static Boolean EqualTargetIDs(const TargetID& inTargetIDOne, const TargetID& inTargetIDTwo);
  44.     static Boolean EqualObjectSpecifiers(const AEDesc& inObjectSpecOne, const AEDesc& inObjectSpecTwo);
  45.  
  46. // setting the idle func (set if you provide a more specific idle function, nil means no idle func)
  47. public:
  48.     static void SetIdleFunc(AEIdleProcPtr inIdleFunc);
  49.  
  50. // the default idle event function for use with AESend or AEInteractWithUser
  51. //    (%%%% does not handle mouse moved events, attachments or sleep time [set to 12 ticks])
  52. public:
  53.     static pascal Boolean DefaultAEIdleFunc(EventRecord* inEvent, long* ioSleepTime, RgnHandle* ioMouseRegion);
  54.  
  55. // the null one, that does nothing. use for events during drag and drop, etc.
  56. public:
  57.     static pascal Boolean NullAEIdleFunc(EventRecord* inEvent, long* ioSleepTime, RgnHandle* ioMouseRegion);
  58.  
  59. // the apple event handler that is called in response to recording starting or stopping
  60. private:
  61.     static pascal OSErr RecordingHandler(const AppleEvent* inAppleEvent, AppleEvent* outAEReply, Int32 inRefCon);
  62.  
  63. // storage
  64. private:
  65.     static AEIdleProcPtr sIdleFunc;
  66.     static Boolean sRecording;
  67. };
  68.